<!DOCTYPE html>
<html>
	<head>
  <meta charset="utf-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <title>寄件单</title>
  <!-- Tell the browser to be responsive to screen width -->
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <!-- Font Awesome -->
  <link rel="stylesheet" href="../../plugins/font-awesome/css/font-awesome.min.css">
  <!-- Ionicons -->
  <link rel="stylesheet" href="../../https://code.ionicframework.com/ionicons/2.0.1/css/ionicons.min.css">
 <!-- Theme style -->
  <link rel="stylesheet" href="../../dist/css/adminlte.min.css">
  
  <!-- iCheck -->
  <link rel="stylesheet" href="../../plugins/iCheck/flat/blue.css">
  <!-- Morris chart -->
  <link rel="stylesheet" href="../../plugins/morris/morris.css">
  <!-- jvectormap -->
  <link rel="stylesheet" href="../../plugins/jvectormap/jquery-jvectormap-1.2.2.css">
  <!-- Date Picker -->
  <link rel="stylesheet" href="../../plugins/datepicker/datepicker3.css">
  <!-- Daterange picker -->
  <link rel="stylesheet" href="../../plugins/daterangepicker/daterangepicker-bs3.css">
  <!-- bootstrap wysihtml5 - text editor -->
  <link rel="stylesheet" href="../../plugins/bootstrap-wysihtml5/bootstrap3-wysihtml5.min.css">
  <!-- Google Font: Source Sans Pro -->
  <link href="https://fonts.googleapis.com/css?family=Source+Sans+Pro:300,400,400i,700" rel="stylesheet">

  <script src="../../plugins/jquery/jquery.min.js"></script>
  
<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.min.js"></script>
<!-- Resolve conflict in jQuery UI tooltip with Bootstrap tooltip -->
<script>
  $.widget.bridge('uibutton', $.ui.button)
</script>
<!-- Bootstrap 4 -->
  <link rel="stylesheet" href="../../dist/css/bootstrap.css">

<script src="../../dist/js/jquery-3.0.0.js"></script>
<script src="../../dist/js/bootstrap.js"></script>
<script src="../../plugins/bootstrap/js/bootstrap.bundle.min.js"></script>
<!-- Morris.js charts -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/raphael/2.1.0/raphael-min.js"></script>
<script src="../../plugins/morris/morris.min.js"></script>
<!-- Sparkline -->
<script src="../../plugins/sparkline/jquery.sparkline.min.js"></script>
<!-- jvectormap -->
<script src="../../plugins/jvectormap/jquery-jvectormap-1.2.2.min.js"></script>
<script src="../../plugins/jvectormap/jquery-jvectormap-world-mill-en.js"></script>
<!-- jQuery Knob Chart -->
<script src="../../plugins/knob/jquery.knob.js"></script>
<!-- daterangepicker -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.10.2/moment.min.js"></script>
<script src="../../plugins/daterangepicker/daterangepicker.js"></script>
<!-- datepicker -->
<script src="../../plugins/datepicker/bootstrap-datepicker.js"></script>
<!-- Bootstrap WYSIHTML5 -->
<script src="../../plugins/bootstrap-wysihtml5/bootstrap3-wysihtml5.all.min.js"></script>
<!-- Slimscroll -->
<script src="../../plugins/slimScroll/jquery.slimscroll.min.js"></script>
<!-- FastClick -->
<script src="../../plugins/fastclick/fastclick.js"></script>
<!-- AdminLTE App -->
<script src="../../dist/js/adminlte.js"></script>
<!-- AdminLTE dashboard demo (This is only for demo purposes) -->
<script src="../../dist/js/pages/dashboard.js"></script>
<!-- AdminLTE for demo purposes -->
<script src="../../dist/js/demo.js"></script>

  
  
</head>
	<body>
		
		<div class="fudong" id="rrr">
			
		 <button class="btn btn-default" onclick="quan()">选中装车</button>
		 <button  class="btn btn-default"  onclick="cha()">查看已装车物件信息</button>
		
		<select class="form-control select2 select2-hidden-accessible" style="width: 15%;"  id="ying">
              <option value="">选择营业厅</option>
      </select>
		
		
		<select class="form-control select2 select2-hidden-accessible" style="width: 15%;"  id="zhong">
              <option value="">选择中转站</option>
      </select>
      
      <select class="form-control select2 select2-hidden-accessible" style="width: 18%;"  id="che">
              <option value="">选择车辆编号</option>
      </select>
      
       <input   class="form-control select2 select2-hidden-accessible" onkeyup="value=value.replace(/[^\d]/g,'')" style="width:185px"  id="yunfei"  placeholder="输入运费"/>
      	<input   class="form-control select2 select2-hidden-accessible" onkeyup="value=value.replace(/[^\d]/g,'')" style="width:185px"  id="qiyun"  placeholder="输入汽运编号"/>

      </div>






<!--shou-->
<div class="shoukuan" id="qqq" style="display: none;">
		 <button class="btn btn-default" onclick="yys()">生成收款</button>
		 <button  class="btn btn-default"  onclick="cha()">查看已装车物件信息</button>
		 

		
		<select class="form-control select2 select2-hidden-accessible" style="width: 15%;"  id="kuaidiyuan">
              <option value="">选择快递员</option>
      </select>
      	  <input   class="form-control select2 select2-hidden-accessible" onkeyup="value=value.replace(/[^\d]/g,'')" style="width:185px"  id="jinge"  placeholder="输入收款金额"/>
		  <input  class="form-control select2 select2-hidden-accessible" onkeyup="value=value.replace(/[^\d]/g,'')" style="width:185px"  id="bianhao"  placeholder="快件编号"/>
      </div>

		
		
		<table id="tab"  class="table table-bordered table-striped table-hover" >
     	<tr align="center">
     	 <td><input type='checkbox' name="selectall" />全选</td>
     	<td>编号</td>
     	<td>出发日期</td>
     	<td>预计到达日期</td>
     	<td>总价</td>
     	<td>寄件人</td>
     	<td>收件人</td>
     	<td>订单类型</td>
     	<td>可否签收</td>
     	<td>包装费</td>	
     	<td>货物信息</td>
     	<td>运输状态</td>
     	<td>寄件人电话</td>
     	<td>\</td>
     	</tr>
     </table>  
     
    <div align="center">
                <ul id="page" class="pagination pagination-lg m-0 float-right">
                </ul>
              </div>
     
     
		<script>
		/*上一页*/
	 function previous(pageNum,totalPage){
	 	
			if(pageNum<=1){
				pageNum=1;
			}
			$("#page").empty();
			 $("#tab tr:gt(0)").empty();
             $("#tab tr").not(':eq(0)').empty();
             
		$.ajax({
				 type: "post", //请求方式
				 async: true, //是否异步
				 url: "http://localhost:8071/happy",
				 data:{"sid":2,"pageNum":pageNum},
				 xhrFields:{withCredentials:true},
				 crossDomain:true,/*ajax跨域请求获取cookies和session*/
				 dataType: "json", //跨域json请求一定是jsonp
				 // jsonp: "callback", //跨域请求的参数名，默认是callback
				 //jsonpCallback:"successCallback",    //自定义跨域参数值，回调函数名也是一样，默认为jQuery自动生成的字符串数
				beforeSend: function() {
					 //请求前的处理
					//alert("请求前")‘
				},success: function(data) {
		    $("#page").append("<li class='page-item' onclick='previous("+(data.pageNum-1)+","+data.totalPage+")' ><a class='page-link float-left' href='#'>&laquo;</a></li>"); 

				$.each(data.list, function(i,d) {
				$("#tab").append("<tr align='center'><td><input type='hidden' name='sasid' value='"+d.sasid+"' /><input type='checkbox' name='storage' /></td><td>"+d.sasid+"</td><td>"+d.starting+"</td><td>"+d.requiredDate+"</td><td>"+d.totalvalue+"</td><td>"+d.senderinformation+"</td><td>"+d.consigneeinformation+"</td><td>"+d.ordertype+"</td><td>"+d.cansignforit+"</td><td>"+d.packaging+"</td><td>"+d.cargoinformation+"</td><td>"+d.sendercontactway+"</td><td>"+d.concontactway+"</td><td><button  onclick='shou("+d.sasid+","+d.cargoinformation+")'>收款</button></td></tr>")
				 	
				 	});
				 	
		    $("#page").append("<li class='page-item' onclick='next("+(data.pageNum+1)+","+data.totalPage+")'><a class='page-link float-right' href='#'>&raquo;</a></li>"); 
  
				 //请求成功处理，和本地回调完全一样
				},		
				 error: function() {
					 //请求出错处理
					
				}
	});
			
	}
	 /*下一页*/
		function next(pageNum,totalPage){
             if(pageNum>=totalPage){
             	pageNum=totalPage;
             }
             $("#page").empty();
             $("#tab tr:gt(0)").empty();
             $("#tab tr").not(':eq(0)').empty();

            $.ajax({
				 type: "post", //请求方式
				 async: true, //是否异步
				 url: "http://localhost:8071/happy",
				 data:{"sid":2,"pageNum":pageNum},
				 xhrFields:{withCredentials:true},
				 crossDomain:true,/*ajax跨域请求获取cookies和session*/
				 dataType: "json", //跨域json请求一定是jsonp
				 // jsonp: "callback", //跨域请求的参数名，默认是callback
				 //jsonpCallback:"successCallback",    //自定义跨域参数值，回调函数名也是一样，默认为jQuery自动生成的字符串数
				beforeSend: function() {
					 //请求前的处理
					//alert("请求前")‘
				},success: function(data) {
		    $("#page").append("<li class='page-item' onclick='previous("+(data.pageNum-1)+","+data.totalPage+")' ><a class='page-link float-left' href='#'>&laquo;</a></li>"); 

				$.each(data.list, function(i,d) {
				$("#tab").append("<tr align='center'><td><input type='hidden' name='sasid' value='"+d.sasid+"' /><input type='checkbox' name='storage' /></td><td>"+d.sasid+"</td><td>"+d.starting+"</td><td>"+d.requiredDate+"</td><td>"+d.totalvalue+"</td><td>"+d.senderinformation+"</td><td>"+d.consigneeinformation+"</td><td>"+d.ordertype+"</td><td>"+d.cansignforit+"</td><td>"+d.packaging+"</td><td>"+d.cargoinformation+"</td><td>"+d.sendercontactway+"</td><td>"+d.concontactway+"</td><td><button  onclick='shou("+d.cargoinformation+")'>收款</button></td></tr>")
				 	
				 	});
				 	
		    $("#page").append("<li class='page-item' onclick='next("+(data.pageNum+1)+","+data.totalPage+")'><a class='page-link float-right' href='#'>&raquo;</a></li>"); 
  
				 //请求成功处理，和本地回调完全一样
				},		
				 error: function() {
					 //请求出错处理
					
				}
	});
		}
		
		/*查询车辆*/
		$.ajax({
				 type: "post", //请求方式
				 async: true, //是否异步
				 url: "http://localhost:8071/selectpai",
				  xhrFields:{withCredentials:true},
				 crossDomain:true,/*ajax跨域请求获取cookies和session*/
				 dataType: "json", //跨域json请求一定是jsonp
				 // jsonp: "callback", //跨域请求的参数名，默认是callback
				 //jsonpCallback:"successCallback",    //自定义跨域参数值，回调函数名也是一样，默认为jQuery自动生成的字符串数
				beforeSend: function() {
					 //请求前的处理
					//alert("请求前")
				},success: function(data) {
				   
				 	$.each(data, function(i,d) {
				 	 $("#che" ).append("<option value='"+data[i].cid+"'>"+data[i].cid+"</option>")	
				 						 });
					 //请求成功处理，和本地回调完全一样
				},		
				 error: function() {
					 //请求出错处理
				}
	});
	
		
		/*查询中转中心*/
			$.ajax({
				 type: "post", //请求方式
				 async: true, //是否异步
				 url: "http://localhost:8071/selectwithtransferstation",
				  xhrFields:{withCredentials:true},
				 crossDomain:true,/*ajax跨域请求获取cookies和session*/
				 dataType: "json", //跨域json请求一定是jsonp
				 // jsonp: "callback", //跨域请求的参数名，默认是callback
				 //jsonpCallback:"successCallback",    //自定义跨域参数值，回调函数名也是一样，默认为jQuery自动生成的字符串数
				beforeSend: function() {
					 //请求前的处理
					//alert("请求前")
				},success: function(data) {
				   
				 	$.each(data, function(i,d) {
				 	  $("#zhong" ).append("<option value='"+data[i].tid+"'>"+data[i].tname+"</option>")		
				 						 });
					 //请求成功处理，和本地回调完全一样
				},		
				 error: function() {
					 //请求出错处理
				}
	});
		
		
		/*查询营业厅*/
			$.ajax({
				 type: "post", //请求方式
				 async: true, //是否异步
				 url: "http://localhost:8071/selectwithhall",
				  xhrFields:{withCredentials:true},
				 crossDomain:true,/*ajax跨域请求获取cookies和session*/
				 dataType: "json", //跨域json请求一定是jsonp
				 // jsonp: "callback", //跨域请求的参数名，默认是callback
				 //jsonpCallback:"successCallback",    //自定义跨域参数值，回调函数名也是一样，默认为jQuery自动生成的字符串数
				beforeSend: function() {
					 //请求前的处理
					//alert("请求前")
				},success: function(data) {
				   
				 	$.each(data, function(i,d) {
				 	 $("#ying").append("<option value='"+data[i].hid+"'>"+data[i].hname+"</option>")	
				 						 });
					 //请求成功处理，和本地回调完全一样
				},		
				 error: function() {
					 //请求出错处理
				}
	});
	
		
	
	/*生成装车单*/
	function quan(){
		
		
		
		if($("#shijian").val()=="" ||$("#ying").val()=="" || $("#zhong").val()=="" || $("#che").val()=="" || $("#qiyun").val()==""|| $("#yunfei").val()==""){
    		alert("请选择或填写相应的信息");
    		throw SyntaxError();
    	}
		
		
		var sasids="";
		/*选中生成装车单的id*/
		 var check=$("input[name='storage']:checked");
		 check.each(function(){
		 var row=$(this).parent("td").parent("tr");
	 	 sasids=row.children().eq(1).text();//注意html()和val()
		 
		 });
		 
		 /*修改状态*/
		 $.ajax({
				 type: "post", //请求方式
				 async: true, //是否异步
				 url: "http://localhost:8071/updateissignforit",
				 xhrFields:{withCredentials:true},
				 data:{"sasid":sasids,"hid":yings,"tid":zhongs},
				 crossDomain:true,/*ajax跨域请求获取cookies和session*/
				 dataType: "json", //跨域json请求一定是jsonp
				 // jsonp: "callback", //跨域请求的参数名，默认是callback
				 //jsonpCallback:"successCallback",    //自定义跨域参数值，回调函数名也是一样，默认为jQuery自动生成的字符串数
				beforeSend: function() {
					 //请求前的处理
					//alert("请求前")‘
				},success: function(data) {
				},		
				 error: function() {
				}
	});
	
	
	
	
	
	
	    var yings   = $("#ying").val();
		var zhongs  = $("#zhong").val();
		var ches    = $("#che").val();
		var qiyuns  = $("#qiyun").val();
		var yunfeis = $("#yunfei").val();
		var shjians =  $("#shijian").val();
		
	/*生成*/
		 $.ajax({
				 type: "post", //请求方式
				 async: true, //是否异步
				 url: "http://localhost:8071/inserthload",
				 xhrFields:{withCredentials:true},
				 data:{"hid":yings,"tid":zhongs,"cid":ches,"trucksnumber":qiyuns,"carriage":yunfeis,"truckdate":shjians},
				 crossDomain:true,/*ajax跨域请求获取cookies和session*/
				 dataType: "json", //跨域json请求一定是jsonp
				 // jsonp: "callback", //跨域请求的参数名，默认是callback
				 //jsonpCallback:"successCallback",    //自定义跨域参数值，回调函数名也是一样，默认为jQuery自动生成的字符串数
				beforeSend: function() {
					 //请求前的处理
					//alert("请求前")‘
				},success: function(data) {
				window.location.reload();
				},		
				 error: function() {
				}
	});
	
	}
	
     	/*全选*/
	   $('input[name="selectall"]').click(function(){ 
             if($(this).is(':checked')){  
                $('input[name="storage"]').each(function(){  
                    //此处如果用attr，会出现第三次失效的情况  
                    $(this).prop("checked",true);  
                });  
        }else{  
            $('input[name="storage"]').each(function(){  
                    $(this).prop("checked",false);  
                });  
        } 
    });
	
	
	/*查询未入库所有*/
	$.ajax({
				 type: "post", //请求方式
				 async: true, //是否异步
				 url: "http://localhost:8071/happy",
				 xhrFields:{withCredentials:true},
				 crossDomain:true,/*ajax跨域请求获取cookies和session*/
				 dataType: "json", //跨域json请求一定是jsonp
				 // jsonp: "callback", //跨域请求的参数名，默认是callback
				 //jsonpCallback:"successCallback",    //自定义跨域参数值，回调函数名也是一样，默认为jQuery自动生成的字符串数
				beforeSend: function() {
					 //请求前的处理
					//alert("请求前")‘
				},success: function(data) {
		    $("#page").append("<li class='page-item' onclick='previous("+(data.pageNum-1)+","+data.totalPage+")' ><a class='page-link float-left' href='#'>&laquo;</a></li>"); 

				$.each(data.list, function(i,d) {
				$("#tab").append("<tr align='center'><td><input type='hidden' name='sasid' value='"+d.sasid+"' /><input type='checkbox' name='storage' /></td><td>"+d.sasid+"</td><td>"+d.starting+"</td><td>"+d.requiredDate+"</td><td>"+d.totalvalue+"</td><td>"+d.senderinformation+"</td><td>"+d.consigneeinformation+"</td><td>"+d.ordertype+"</td><td>"+d.cansignforit+"</td><td>"+d.packaging+"</td><td>"+d.cargoinformation+"</td><td>"+d.sendercontactway+"</td><td>"+d.concontactway+"</td><td><button  onclick='shou("+d.sasid+")'>收款</button></td></tr>")
				 	
				 	});
				 	
		    $("#page").append("<li class='page-item' onclick='next("+(data.pageNum+1)+","+data.totalPage+")'><a class='page-link float-right' href='#'>&raquo;</a></li>"); 
  
				 //请求成功处理，和本地回调完全一样
				},		
				 error: function() {
					 //请求出错处理
					
				}
	});
	
	function shou(sasid){
		$("#qqq").show();
		$("#bianhao").val(sasid);
		var mane = $()
		$.ajax({
				 type: "post", //请求方式
				 async: true, //是否异步
				 url: "http://localhost:8071/selectstaff",
				  xhrFields:{withCredentials:true},
				 crossDomain:true,/*ajax跨域请求获取cookies和session*/
				 dataType: "json", //跨域json请求一定是jsonp
				 // jsonp: "callback", //跨域请求的参数名，默认是callback
				 //jsonpCallback:"successCallback",    //自定义跨域参数值，回调函数名也是一样，默认为jQuery自动生成的字符串数
				beforeSend: function() {
					 //请求前的处理
					//alert("请求前")
				},success: function(data) {
				   
				 	$.each(data, function(i,d) {
				 	 $("#kuaidiyuan").append("<option value='"+data[i].sid+"'>"+data[i].name+"</option>")	
				 						 });
					 //请求成功处理，和本地回调完全一样
				},		
				 error: function() {
					 //请求出错处理
				}
	});
	$("#qqq").hidden();
	
		
	}
	
        
		
		function yys(){
	    var jinge   =   $("#jinge").val();
		var kuaidiyuan  = $("#kuaidiyuan").val();
		var bianhao    = $("#bianhao").val();
		var mingcheng  = $("#mingcheng").val();
	   alert(jinge)
		if($("#jinge").val()=="" ||$("#kuaidiyuan").val()=="" ){
    		alert("请选择或填写相应的信息");
    		throw SyntaxError();
    	}
	
	 $.ajax({
				 type: "post", //请求方式
				 async: true, //是否异步
				 url: "http://localhost:8071/addpayee",
				 xhrFields:{withCredentials:true},
				 data:{"pamoney":jinge,"sid":kuaidiyuan,"sasid":bianhao},
				 crossDomain:true,/*ajax跨域请求获取cookies和session*/
				 dataType: "json", //跨域json请求一定是jsonp
				 // jsonp: "callback", //跨域请求的参数名，默认是callback
				 //jsonpCallback:"successCallback",    //自定义跨域参数值，回调函数名也是一样，默认为jQuery自动生成的字符串数
				beforeSend: function() {
					 //请求前的处理
					//alert("请求前")‘
				},success: function(data) {
				window.location.reload();
				},		
				 error: function() {
				}
	});
	
	
	
	}
	
	
	
	
	function cha(){
		$("#rrr").empty();
			$("#tab").empty();
			$("#tab").append("<iframe width='100%' height='800px'  frameborder='0' src='wang.html'></iframe>");

		}

	
</script>
	
	<style>
		
.fudong div ,select,input{
float:left;
}
		
		
	</style>
	
</html>
